package com.albaba.designpattern.facade.text_002;

/**
 * @Description: TODO
 * @Author zx
 * @Date 2025/2/21 10:37
 * @Version 1.0
 */
public class SmartAppliancesFacade {

    private Light light;

    private TV tv;

    private AriCondition ariCondition;

    public SmartAppliancesFacade() {
        light = new Light();
        tv = new TV();
        ariCondition = new AriCondition();
    }

    public void say(String message) {
        if (message.contains("打开")) {
            if (message.contains("灯")) {
                light.on();
            } else if (message.contains("电视")) {
                tv.on();
            } else if (message.contains("空调")) {
                ariCondition.on();
            } else if (message.contains("家电")) {
                on();
            }else {
                System.out.println("没听清您在说什么，请重新发起指令");
            }
        }
    }

    public void close() {
        light.off();
        tv.off();
        ariCondition.off();
    }

    private void on() {
        System.out.println("起床了");
        light.on();
        tv.on();
        ariCondition.on();
    }

    private void off() {
        System.out.println("睡觉了");
        light.off();
        tv.off();
        ariCondition.off();
    }


}
